﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 多态
{
    class HourlyEmployee : Employee
    {
        private decimal hours;
        private decimal wage;//wage per hour

        public HourlyEmployee(string first, string last, string num, decimal h, decimal w)
            : base(first, last, num)
        {
            Hours = h;
            Wage = w;
        }

        public override string  ToString()
        {
            return string.Format("{0}\nhours worked: {1:F2}\n Hourly wage: {2:C}", base.ToString(), Hours, Wage);
        }

        public override decimal Earning()
        {
            return Wage * Hours;
        }

        public decimal Hours
        {
            get
            {
                return hours;
            }
            set
            {
                hours = ((value >= 0) && (value <= 168)) ? value : 0;
            }
        }

        public decimal Wage
        {
            get
            {
                return wage;
            }
            set
            {
                wage = (value >= 0) ? value : 0;
            }
        }
    }//end class HourlyEmployee
}
